package com.yisoo.ubag.product.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.yisoo.ubag.product.entity.DevTokenEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.yisoo.ubag.product.entity.DevSecBraConEntity;
import com.yisoo.ubag.product.service.DevSecBraConService;
import com.yisoo.common.utils.PageUtils;
import com.yisoo.common.utils.R;



/**
 * 
 *
 * @author mmciel
 * @email 761998179@qq.com
 * @date 2021-02-07 17:11:37
 */
@RestController
@RequestMapping("product/devsecbracon")
public class DevSecBraConController {
    @Autowired
    private DevSecBraConService devSecBraConService;


    //检查指定品牌和场景的剩余token数量
    @RequestMapping("/residue")
    public R getresidue(@RequestBody DevTokenEntity devTokenEntity){
        List<DevTokenEntity> residue = devSecBraConService.getResidue(devTokenEntity);
        return R.ok().put("count",residue.size());
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("product:devsecbracon:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = devSecBraConService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{devId}")
    //@RequiresPermissions("product:devsecbracon:info")
    public R info(@PathVariable("devId") Long devId){
		DevSecBraConEntity devSecBraCon = devSecBraConService.getById(devId);

        return R.ok().put("devSecBraCon", devSecBraCon);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("product:devsecbracon:save")
    public R save(@RequestBody DevSecBraConEntity devSecBraCon){
		devSecBraConService.save(devSecBraCon);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("product:devsecbracon:update")
    public R update(@RequestBody DevSecBraConEntity devSecBraCon){
		devSecBraConService.updateById(devSecBraCon);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("product:devsecbracon:delete")
    public R delete(@RequestBody Long[] devIds){
		devSecBraConService.removeByIds(Arrays.asList(devIds));

        return R.ok();
    }

}
